from sqlalchemy import (
    create_engine,
)
from llama_index.llms.openai import OpenAI
from llama_index.core.query_engine import NLSQLTableQueryEngine


llm = OpenAI(temperature=0.1,
              model="gpt-3.5-turbo",
              api_key="sk-cRQTbPKmHqDn3zrV1f7c3443C3644bB3A0BdFeC506458936",
              api_base="https://hf.xty.app/ ")

engine = create_engine("sqlite:///data/test.db", future=True)
query_engine = NLSQLTableQueryEngine(
    sql_database=engine, tables=["students","grade"], llm=llm
)
query_str = "告诉我数学最高分是哪个人?"
response = query_engine.query(query_str)